package com.example.test2;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabWidget;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private Button button2;
    private LinearLayout a;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

        //底部导航栏
        TabHost tabHost = findViewById(android.R.id.tabhost);
        TabWidget tabs = findViewById(android.R.id.tabs);
        tabHost.setup();
        LayoutInflater inflater = LayoutInflater.from(this);
        inflater.inflate(R.layout.activity_tabl1, tabHost.getTabContentView());
        inflater.inflate(R.layout.activity_tabl2, tabHost.getTabContentView());
//        inflater.inflate(R.layout.activity_tabl3, tabHost.getTabContentView());
        tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("发现").setContent(R.id.left));
        tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("我的").setContent(R.id.center));
//        tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("关注").setContent(R.id.right));

        initView();

        //歌词跳转Activity
        a.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this,IyricActivity.class);
                startActivity(intent);
            }
        });

        //搜索跳转Activity
        View view = View.inflate(getApplicationContext(), R.layout.activity_tabl1, null);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SearchActivity.class);
                startActivity(intent);
            }
        });
    }

    private void initView() {
        button2 = (Button) findViewById(R.id.button2);
        a = (LinearLayout) findViewById(R.id.a);
    }
}